package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.time.LocalDateTime;

@Mapper
public interface UserMapper {
    /**
     * 根据openid查找用户
     * @param openid
     * @return
     */
    @Select("select * from user where openid=#{openid}")
    User selectByOpenid(String openid);

    /**
     * 插入新用户
     * @param user
     * @return
     */
    int insertUser(User user);

    /**
     * 根据用户id查询用户信息
     * @param userId
     * @return
     */
    @Select("select * from user where id=#{userId}")
    User selectById(Long userId);

    /**
     * 统计某个时间段注册的用户数量
     * @param beginTime 统计开始时间
     * @param endTime 统计结束时间
     * @return 数量
     */
    Integer countByCrtRange(LocalDateTime beginTime,LocalDateTime endTime);

}
